package com.yang.libs.mvppresenter

import com.blankj.utilcode.util.ToastUtils
import com.xxx.lib.base.BasePresenter
import com.xxx.lib.net.observer.XxBaseHttpObserver
import com.yang.libs.bean.MainBean
import com.yang.libs.datasource.RemoteDataSource
import com.yang.libs.mvpview.MainView

class MainPresenter : BasePresenter<MainView>() {

    fun getMallData() {
        RemoteDataSource.getMainData(object : XxBaseHttpObserver<MainBean>() {

            override fun onSuccess(msg: String?, bean: MainBean?) {
                getView()?.getMainDataSuccess(bean ?: return)
            }

            override fun onFail(msg: String?, code: String?) {
                ToastUtils.showShort(msg)
                getView()?.getMainDataFail()
            }

            override fun onShowLoadingDialog() {
                getView()?.showLoadingDialog()
            }

            override fun onDismissLoadingDialog() {
                getView()?.dismissLoadingDialog()
            }
        })
    }

}